<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
        <h1>{{msg}}</h1>
        <son @handler='getData'></son>
    </div>

    <script src="./vue.js"></script>
    <script>
      Vue.component("son", {
        data() {
            return {
                msg:"son's data"
            }
        },
        methods:{
            send() {
                this.$emit('handler',this.msg)
            }
        },
        template: `<button @click='send'>click</button>`
      });
      var vm = new Vue({
        el: "#app",
        data: {
            msg:""
        },
        methods: {
            getData(res) {
                console.log(res);
                this.msg = res
            }
        },
      });
    </script>
  </body>
</html>
